<?php

namespace App\Services;

use App\Models\ArticleCategories;


class ArticleCategoriesService extends BaseService
{
    /**
     * 获取列表
     * @return
     */
    public function list($page,$limit,$sort,$order, $name,$isopen,$nav) {
        $query = ArticleCategories::query();
        if(!empty($name)){
            $query->where('name','like',"%$name%");
        }
        if(isset($isopen)){
            $query->where('isopen',$isopen);
        }
        if(isset($nav)){
            $query->where('nav',$nav);
        }
        return $query->orderBy($sort,$order)->paginate($limit, ['*'], 'page', $page);
    }

    /**
     * 获取所有
     * @return
     */
    public function listAll($name,$isopen,$sort,$order,$nav) {
        $query = ArticleCategories::query();
        if(!empty($name)){
            $query->where('name','like',"%$name%");
        }
        if(isset($isopen)){
            $query->where('isopen',$isopen);
        }
        if(isset($nav)){
            $query->where('nav',$nav);
        }
        return $query->orderBy($sort,$order)->get();
    }
}
